home *** CD-ROM | disk | FTP | other *** search
- /* Convert data from a text file
- max min zero_line
- to a lise spectrum
- */
-
- #include <stdio.h>
- #include <spec.h>
-
- float x,y,*spc,*err,*tim;
-
- help()
- {
- printf("dat2l lisespec textfile timecal ycal\n");
- printf(" converts spectra from a textfile to lise format\n");
- printf(" file format:\n");
- printf(" ymax ymin zero_line\n");
- }
-
- iabs(x)
- int x;
- {
- if(x >= 0) return(x);
- return(-1 * x);
- }
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int n,m,i,max;
- int y1,y2,y0;
- char z[80],comment[80];
- FILE *fp;
- float ycal;
-
- if(argc != 5) {
- help();
- exit(0);
- }
-
- spc= (float *)calloc(_MAXSPCLEN+2,sizeof(float));
- err= (float *)calloc(_MAXSPCLEN+2,sizeof(float));
- tim= (float *)calloc(_MAXSPCLEN+2,sizeof(float));
- if(tim==NULL) {
- printf("sorry, not enough memory\n");
- exit(-1);
- }
-
- strcpy(z,argv[2]);
- fp = fopen(z,"r");
- if(fp == NULL) {
- printf("Could not open file >%s<\n",z);
- exit(0);
- }
-
- _tica = atosf(argv[3]);
- ycal = atosf(argv[4]);
- max = 0;
- while(!feof(fp)) {
- fscanf(fp,"%d %d %d\n",&y1,&y2,&y0);
- i = iabs(y1 - y2);
- err[max] = 0.5 * ycal * (float) i;
- i = (y1 + y2) >> 1;
- i = i - y0;
- spc[max] = ycal * (float) i;
- tim[max] = _tica * (float) max;
- max = max + 1;
- }
-
- strcpy(z,argv[1]);
- writespec(z,spc,err,max,2,"lazarus");
- strcat(z,".tim");
- writespec(z,tim,err,max,2,"lazarus");
- free(err); free(spc); free(tim);
- exit(0);
- }
-
-